package com.learn.training.multithread.chapter10.demo2;

import java.util.Arrays;
import java.util.concurrent.ForkJoinPool;

public class Demo {

    public static void main(String[] args) {
        int[] array = new int[100];
        // 初始化数组
        for (int i = 0; i < array.length; i++){
            array[i] = i + 1;
        }
        System.out.println(Arrays.toString(array));

        // ForkJoinPool 管理和执行 ForkJoin 任务
        ForkJoinPool pool = new ForkJoinPool();
        RecursiveActionExample task = new RecursiveActionExample(array, 0, array.length - 1);
        pool.invoke(task);

        // 输出结果
        System.out.println(Arrays.toString(array));
    }
}
